from aiqicha.aiqicha import AiqichaScan
from rapiddns.rapiddns import RapidDNS
from cyber_search_engine.zoomeye import Zoomeye
from workflow_domain import workflow_domain_ip
from utils.log import logger

def workflow_keyword(keyword):
    """从关键字中获取目标所有信息"""
    cookie = ''
    aiqicha = AiqichaScan(cookie, keyword)

    # 查找关键字对应的组织
    aiqicha.get_basic_info()
    if not aiqicha.company_name:
        logger.error(f'{keyword} 搜索失败，程序退出')
        exit(0)

    # 查找组织对应的网络信息
    aiqicha.get_advance_info()

    # 文件导出
    aiqicha.exports()
    # xlsx_save_path = aiqicha.save_path

    # 获取所有的域名信息
    domains = aiqicha.domains
    if len(domains) == 0:
        logger.warning(f'{aiqicha.company_name} 没有网站备案内容，无法进一步收集信息')
        exit(0)
    # 网络信息扫描
    # workflow_domain_ip(domains, xlsx_save_path)


if __name__ == '__main__':
    keyword_example = input('>> 请输入关键字(示意: 北京先导视觉): ')
    workflow_keyword(keyword_example)
